<template>
    <div>
        <el-card class="box-card">
            <div slot="header" class="clearfix">
                <el-button style="float: right; padding: 3px 0" type="text" @click="informationList">更多</el-button>
                <span>
                    <h1>招聘资讯</h1>
                </span>
            </div>
        </el-card>
        <el-row>
            <el-col :span="6" v-for="information in informations" :key="information.article_id">
                <div>
                    <el-card :body-style="{ padding: '0px' }">
                        <img :src="information.url" class="image">
                        <div style="padding: 14px;" @click="informationDetail(information.article_id)">
                            <span>{{ information.title }}</span>
                            <div class="bottom clearfix">
                                点击量:<span>{{ information.hits }}</span>
                                点赞数:<span>{{ information.praise_len }}</span>
                                <span>
                                    发布时间:<time class="time">{{ format(information.create_time).format }}</time>
                                </span>
                                <el-button type="text" class="button"
                                    @click="informationDetail(article_id)">查看详情</el-button>
                            </div>
                        </div>
                    </el-card>
                </div>
            </el-col>
        </el-row>
    </div>
</template>
<script>
import axios from 'axios';
import dateTime from '@/utils/date_time';
export default {
    data() {
        return {
            informations: [],
        }
    },
    methods: {
        informationDetail(id) {
            this.$router.push({ name: 'information_detail', params: { article_id: id } }, () => { }, () => { });
        },
        informationList() {
            this.$router.push({ path: '/information/list' }, () => { }, () => { });
        },
        format(create_time) {
            return dateTime.dateTime(create_time)
        }
    },
    created: function () {
        let that = this;
        axios.get('http://127.0.0.1:5000/api/article/get_list', {
            params: {
                page: 1,
                size: 4
            }
        })
            .then(function (response) {
                console.log(response.data.result);
                that.informations = response.data.result.list;
            })
            .catch(function (error) {
                console.log(error);
            })
            .then(function () {
                // 总是会执行
            })
    },
}
</script>
<style lang="less" scoped>
.text {
    font-size: 14px;
}

.item {
    padding: 18px 0;
}

.box-card {
    margin-left: 200px;
    margin-right: 200px;
    width: 1500px;
    height: 100px;
}
</style>